public class FruitWithDiscount extends Fruit{
    // 定义折扣策略
    private DiscountStrategy discountStrategy;
    // 构造函数，传入水果名称、每公斤价格和折扣策略
    public FruitWithDiscount(String name, double pricePerKg, DiscountStrategy discountStrategy) {
        super(name, pricePerKg);
        this.discountStrategy = discountStrategy;
    }
    // 重写计算价格方法，使用折扣策略计算价格
    @Override
    public double calculatePrice(int weight) {
        return discountStrategy.applyDiscount(weight * pricePerKg);
    }
}
